//
//  HECircleChatManager.h
//  HealthFamily
//
//  Created by 吴欧 on 2021/2/25.
//  Copyright © 2021 honglutec. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "HEChatRoomModel.h"
#import "HEIMCircleChatController.h"
#import "HEIMKitInfo.h"

typedef NS_ENUM(NSUInteger, HETeamOperationType) {
    
    /**
     *  离开群
     */
    HETeamOperationTypeLeave = 0,
    
    /**
     *  加入群
     */
    HETeamOperationTypeJoin  = 1,
};

typedef NS_ENUM(NSUInteger, HETeamStatusType) {
    
    /**
     *  删除群
     */
    HETeamStatusTypeDelete = 0,
    
    /**
     *  新增群
     */
    HETeamStatusTypeAdd    = 1,
};

NS_ASSUME_NONNULL_BEGIN

@protocol HECircleChatManagerDelegate <NSObject>

@optional
/**
 获取聊天室列表
 */
- (void)allTeams:(NSArray <HEChatRoomModel *> *)teams;

/**
 更新某个聊天室信息
 */
- (void)updateTeamInfo:(HEChatRoomModel *)team index:(NSInteger)index;

/**
 发送消息前回调，用于tableview 添加发送时的数据
 */
- (void)sendMessageBefore:(HEIMMessageModel *)message;

/// 消息发送后回调
- (void)sendMessageCallback:(HEIMMessage *)message;

/**
 某个聊天室的所有用户
 */
- (void)teamAllUsers:(NSArray <HEIMKitInfo *> *)teams;

/**
 某个聊天室的用户列表数量变化，0 减少 1 增加
 */
- (void)teamUserChangeInfo:(HEChatRoomModel *)user;

/**
 接收聊天室消息
 */
- (void)onRecvMessages:(HEIMMessageModel *)message;

@end

@interface HECircleChatManager : NSObject

/// 当前所有聊天室列表
@property (nonatomic, strong) NSMutableArray <HEChatRoomModel *> *teams;

/// 当前聊天室内的人员列表
@property (nonatomic, weak) NSMutableArray <HEIMKitInfo *> *currentUserList;

/// 当前是否在房间
@property (nonatomic, assign) BOOL isInRoom;


+ (instancetype)sharedManager;

/**
 *  添加聊天委托
 *
 *  @param delegate 聊天委托
 */
- (void)addDelegate:(id<HECircleChatManagerDelegate>)delegate;

/**
 *  移除聊天委托
 *
 *  @param delegate 聊天委托
 */
- (void)removeDelegate:(id<HECircleChatManagerDelegate>)delegate;

/**
 *  移除所有聊天委托
 *
 *  @param delegate 聊天委托
 */
- (void)removeAllDelegate;

/**
 初始化
 */
- (void)initOpration;

/**
  加入聊天室
 */
- (void)joinRoom:(HEChatRoomModel *)user callback:(void (^)(BOOL success))callback;
 
/**
  离开聊天室
 */
- (void)leaveRoom;

/**
 *  发送消息
 *  @param message 消息
 */
- (void)sendMessage:(HEIMMessageModel *)message callback:(void (^)(BOOL success))callback;


- (void)switchRoomVC:(HEChatRoomModel *)roomModel isFromChatPage:(BOOL)isFromChatPage callback:(void (^)(HEIMCircleChatController *vc))callback;

/// 聊天室列表人员数量变化
- (void)chatRoomUpHandler:(NSDictionary *)msg;

/// 聊天室消息回调
- (void)chatRoomMsgHandler:(NSDictionary *)msg;

/// 新增、删除聊天室回调
- (void)chatRoomListUpHandler:(NSDictionary *)msg;

/// 关闭 移除所有聊天室
- (void)closeAllRoom;

@end

NS_ASSUME_NONNULL_END
